package it.polimi.TravelDream;

import java.io.Serializable;

import javax.persistence.*;

import java.util.Date;
import java.util.List;


/**
 * The persistent class for the hotel database table.
 * 
 */
@Entity
@NamedQueries({
@NamedQuery(name="Hotel.findAll", query="SELECT h FROM Hotel h"),
@NamedQuery(name="Hotel.searchQuery", query="SELECT h FROM Hotel h WHERE h.city LIKE :param1")
})
public class Hotel implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private int id;

	@Temporal(TemporalType.DATE)
	private Date addDate;

	private String address;

	private int cap;

	private String category;

	private String city;

	private String country;

	private String description;

	private String name;

	@Column(name="`Price/Night`")
	private int price_Night;

	private String website;

	//bi-directional many-to-one association to Basepackage
	@OneToMany(mappedBy="hotel")
	private List<Basepackage> basepackages;

	//bi-directional many-to-one association to User
	@ManyToOne
	@JoinColumn(name="AddedBy")
	private User user;

	//bi-directional many-to-one association to Savedpackage
	@OneToMany(mappedBy="hotel")
	private List<Savedpackage> savedpackages;

	public Hotel() {
		super();
	}
	
	public Hotel(HotelDTO hotel) {
		this.id = hotel.getId();
		this.addDate = new Date();
		this.address = hotel.getAddress();
		this.cap = hotel.getCap();
		this.category = hotel.getCategory();
		this.city = hotel.getCity();
		this.country = hotel.getCountry();
		this.description = hotel.getDescription();
		this.name = hotel.getName();
		this.price_Night = hotel.getPrice_Night();
		this.description = hotel.getDescription();
		this.website = hotel.getWebsite();
	}

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Date getAddDate() {
		return this.addDate;
	}

	public void setAddDate(Date addDate) {
		this.addDate = addDate;
	}

	public String getAddress() {
		return this.address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public int getCap() {
		return this.cap;
	}

	public void setCap(int cap) {
		this.cap = cap;
	}

	public String getCategory() {
		return this.category;
	}

	public void setCategory(String category) {
		this.category = category;
	}

	public String getCity() {
		return this.city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getCountry() {
		return this.country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getPrice_Night() {
		return this.price_Night;
	}

	public void setPrice_Night(int price_Night) {
		this.price_Night = price_Night;
	}

	public String getWebsite() {
		return this.website;
	}

	public void setWebsite(String website) {
		this.website = website;
	}

	public List<Basepackage> getBasepackages() {
		return this.basepackages;
	}

	public void setBasepackages(List<Basepackage> basepackages) {
		this.basepackages = basepackages;
	}

	public Basepackage addBasepackage(Basepackage basepackage) {
		getBasepackages().add(basepackage);
		basepackage.setHotel(this);

		return basepackage;
	}

	public Basepackage removeBasepackage(Basepackage basepackage) {
		getBasepackages().remove(basepackage);
		basepackage.setHotel(null);

		return basepackage;
	}

	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public List<Savedpackage> getSavedpackages() {
		return this.savedpackages;
	}

	public void setSavedpackages(List<Savedpackage> savedpackages) {
		this.savedpackages = savedpackages;
	}

	public Savedpackage addSavedpackage(Savedpackage savedpackage) {
		getSavedpackages().add(savedpackage);
		savedpackage.setHotel(this);

		return savedpackage;
	}

	public Savedpackage removeSavedpackage(Savedpackage savedpackage) {
		getSavedpackages().remove(savedpackage);
		savedpackage.setHotel(null);

		return savedpackage;
	}

}